// Simple program to demonstrate the use of pointers
#include <iostream>
#include <string>

void pointer(int *p)
{
  // Use the dereference operator to access the data at the end of the
  // pointer:
  *p = 3;
}

int main()
{
  int i1 = 7, i2 = 5;

  // Create and initialize some pointers:
  int *p_i = &i1;
  pointer(&i1);

  // Print and change the pointer:
  std::cout << *p_i << std::endl;
  p_i = &i2;
  std::cout << *p_i << std::endl;
  

  // Create a string and a pointer to a string;
  std::string str = "Hello, World\n;";
  std::string *p_str = &str;
  
  // If we want to use member functions we have to use the ->
  // operator:
  std::cout << str.size()      << std::endl
	    << p_str->size()   << std::endl
	    << (*p_str).size() << std::endl;

  void *p_v = &i1;

  return 0;
}
